package com.damai.action.aop.impl;

import javax.servlet.http.HttpServletRequest;

import com.damai.action.aop.Interceptor;
import com.damai.action.aop.Invoker;

public class InvokerChain implements Invoker {
	
	private Interceptor interceptor;
	
	private Invoker invoker;
	
	
	public InvokerChain(Interceptor interceptor,
			Invoker invoker){
		this.interceptor = interceptor;
		this.invoker = invoker;
	}
	
	public void setInvoker(Invoker invoker){
		this.invoker = invoker;
	}
	
	public Invoker getInvoker(){
		return invoker;
	}
	
	public Interceptor getInterceptor(){
		return interceptor;
	}


	@Override
	public Object invoke(HttpServletRequest request, Object[] args) {
		final Interceptor interceptor = this.interceptor;
		final Invoker invoker = this.invoker;
		return interceptor.invoke(invoker, request, args);
	}


}
